#!/usr/bin/env bash

icon() {
    # Lets round the float result
    bri=$(brightnessctl i -m | tr , " " | awk '{print $4}' | cut -c 1-2)
    
    # if [[ "$bri" -gt "90" ]]; then
    #     echo "󰃠"
    #     elif [[ "$bri" -gt "50" ]]; then
    #     echo ""
    #     elif [[ "$bri" -gt "30" ]]; then
    #     echo ""
    # else
    #     echo ""
    # fi
    brightness_percent=$bri
    # 图标：                               
    #    ﯷ ﱫ ﱪ ﳺ  盛 ﱳ ﲏ ﮻  盛 
    #         
    # -eq 等于 -lt 小于 -ne 不等于 -gt 大于 -le 小于等于 -ge 大于等于
    # if   [ "$brightness_percent" -eq 0  ]; then brightness_icon="";
    if   [ "$brightness_percent" -le 3  ]; then brightness_icon="";
    elif [ "$brightness_percent" -lt 10 ]; then brightness_icon="";
    elif [ "$brightness_percent" -le 20 ]; then brightness_icon="";
    elif [ "$brightness_percent" -le 30 ]; then brightness_icon="";
    elif [ "$brightness_percent" -le 40 ]; then brightness_icon="";
    elif [ "$brightness_percent" -le 50 ]; then brightness_icon="";
    elif [ "$brightness_percent" -le 60 ]; then brightness_icon="";
    elif [ "$brightness_percent" -le 70 ]; then brightness_icon="";
    elif [ "$brightness_percent" -le 80 ]; then brightness_icon="";
    elif [ "$brightness_percent" -le 80 ]; then brightness_icon="";
    elif [ "$brightness_percent" -le 95 ]; then brightness_icon="";
    elif [ "$brightness_percent" -le 99 ]; then brightness_icon="";
    elif [ "$brightness_percent" -eq 100 ]; then brightness_icon="盛";
    else brightness_icon=""; 
    fi
    echo $brightness_icon
}

getbri() {
    bri=$(brightnessctl i -m | tr , " " | awk '{print $4}' | cut -c 1-2)
    echo $bri
}

if [[ $1 == "--icon" ]]; then
    icon
    elif [[ $1 == "--value" ]]; then
    getbri
fi